<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Candidate extends MY_Controller {
	
	public function __construct()
	{
		parent::__construct();
        $this->check_authentication(1);
        $this->load->model('Candidate_model', 'candidate');
        $this->lang->load('candidate', $this->session->userdata['user_lang']);
	}
	
	public function index()
	{
		$data['main_content'] = 'candidate/index';
        $data['userdata'] = $this->session->userdata;
        
        $job_list = $this->candidate->get_profile_jobs();
        
		$grid_jobs = array();
        
        foreach ($job_list->result() as $row)
		{
			$grid_jobs[] = '<div class="row"><span><span class="gtitle"><a href="'.base_url().'job/detail/'.$row->id.'/'.str_replace(' ', '-', $row->title).'">' . $row->title . '</a></span>'
			.'<br/><span class="gdesc">'.format_date($row->date, true) . ' - ' . $row->company 
			. '</span></span>
			<div class="gtool">
				<a href="'.base_url().'job/detail/'.$row->id.'/'.str_replace(' ', '-', $row->title).'">'.$this->lang->line('candidate_viewjob').'</a>
				&middot; <a href="'.base_url().'job/request/interview/'.$row->id.'/'.str_replace(' ', '-', $row->title).'" rel="facebox">'.$this->lang->line('candidate_requestinterview').'</a>
			</div>
			</div>';
		}
		
		if (!$grid_jobs) {
			 $data['grid_jobs'] = '<center>'.$this->lang->line('candidate_jobnoresults').'</center><br/>'.
			 $this->lang->line('candidate_changeinterests1') . 
			 ' <a href="'.base_url().'candidate/interests">'.$this->lang->line('candidate_changeinterests2').'</a>' .
			 ' '.$this->lang->line('candidate_changeinterests3');
		} else {
			 $data['grid_jobs'] = implode('<hr/>', $grid_jobs);
		}
		
        $this->load->view('template-candidate', $data);
	}
}

?>